<template>
	<view class="content bgf">
		
		<u-navbar :is-back="true" :title="title" :border-bottom="false" ></u-navbar>
		<my_navbar_ext height="38" bg-color="#ffffff">
			<view style="height: 38px;width: 100%;">
		      <u-search height="70" :disabled="false" @blur="searchGet" placeholder="输入手机/昵称/ID号" :show-action="true" v-model="keyword"></u-search>
		    </view>
		</my_navbar_ext>
		
		<view class="main">
			
			<view v-for="(item,index) in list" :key="item.id" class="disf f30">
				<view class="pt30 pl30 pb10 pr30">
					<image :src="item.head_pic" style="width:85rpx;height: 85rpx;"></image>
				</view>
				<view class="pt30 bbo" style="width: 600rpx;">
					<view class="f34 disfr-lr">
						<view>{{item.nickname}}</view>
						<view class="f28 col999 mr10">
							<button class="custom-min-button" @click="sayHello" :data-id="item.id">打招呼</button>
						</view>
					</view>
					<view class="col999 mt5 f28">ID号：{{item.id}}</view>
				</view>
			</view>
			
			<view v-if="list.length <= 0 && issearch" style="text-align: center;margin-top: 40%;">
				<view><u-icon name="wuneirong-copy" custom-prefix="qxl-icon" color="#999999" size="100"></u-icon></view>
				<view class="f32 col999 mt20">什么都木有哦</view>
			</view>
			
		</view>
		
		<loading :loading="not_load"/><!--加载状态-->
	    
	</view>
</template>

<script setup>
import { onLoad, onShow, onHide } from '@dcloudio/uni-app';
import { ref } from 'vue';	
const show_main=ref(false);
const not_load=ref(false);
const list=ref([]);
const title=ref('打招呼');
const keyword=ref('');
const issearch = ref(false);
//页面加载时
onLoad(async (options)=>{
	show_main.value=true;
	not_load.value=true;
});
//页面显示时执行
onShow(()=>{
	
});
//页面隐藏时执行
onHide(()=>{
	
});
/**
 * 模板属性跳转页面
 * @param {Object} e
 */
function goPage(event){
	uni.$utils.dataSetPage(event);
};
// 搜索用户
const searchGet=async()=>{
	let val=keyword.value;
	if(!val) return;
	issearch.value=true;
	not_load.value=false;
	let ret = await uni.$post('/appapi-config-searchuser',{},{keyword:val});
	not_load.value=true;
	list.value=ret.data.list;
	keyword.value='';
};
// 打招呼 
const sayHello=(e)=>{
	let id=e.currentTarget.dataset.id;
	let str=uni.$appConfig['IM_PREFIX_MAKR']['da_zhao_hu']['rule']+'你好！';
	uni.TIM.createTextMessage(0,id,str,(data)=>{
		uni.$utils.showToast('消息发送成功',0,()=>{
			uni.navigateBack({data:1});
		});
	});
};
</script>

<style  lang="scss">
	page {
		background: #fff;
	}
</style>
